{% extends 'inventory/base.html' %}

{% block title %}充值记录 - {{ block.super }}{% endblock %}

{% block content %}
<div class="row mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <h2 class="card-title mb-0">{{ member.name }} 的充值记录</h2>
                        <p class="text-muted">查看会员的所有充值记录</p>
                    </div>
                    <div class="d-flex gap-2">
                        <a href="{% url 'member_recharge' member.id %}" class="btn btn-success">
                            <i class="bi bi-cash-coin me-1"></i> 充值
                        </a>
                        <a href="{% url 'member_details' member.id %}" class="btn btn-info">
                            <i class="bi bi-person me-1"></i> 会员详情
                        </a>
                        <a href="{% url 'member_list' %}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left me-1"></i> 返回列表
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">充值记录列表</h5>
            </div>
            <div class="card-body">
                {% if recharge_records %}
                <div class="table-responsive">
                    <table class="table table-striped table-hover align-middle">
                        <thead class="table-light">
                            <tr>
                                <th>充值编号</th>
                                <th>充值时间</th>
                                <th>充值金额</th>
                                <th>实收金额</th>
                                <th>支付方式</th>
                                <th>操作员</th>
                                <th>备注</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for record in recharge_records %}
                            <tr>
                                <td>#{{ record.id }}</td>
                                <td>{{ record.created_at|date:"Y-m-d H:i" }}</td>
                                <td>
                                    <span class="fw-bold text-success">¥{{ record.amount }}</span>
                                </td>
                                <td>
                                    <span class="text-muted">¥{{ record.actual_amount }}</span>
                                </td>
                                <td>
                                    <span class="badge bg-secondary">{{ record.get_payment_method_display }}</span>
                                </td>
                                <td>{{ record.operator.username }}</td>
                                <td>
                                    <small class="text-muted">{{ record.remark|default:"-" }}</small>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% else %}
                <div class="text-center py-5">
                    <i class="bi bi-wallet text-muted" style="font-size: 2.5rem;"></i>
                    <p class="mt-3 mb-0">暂无充值记录</p>
                    <a href="{% url 'member_recharge' member.id %}" class="btn btn-success mt-3">
                        <i class="bi bi-cash-coin me-1"></i> 立即充值
                    </a>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %} 